/*
 * POSTagComboBoxModel.java
 *
 * Created on April 23, 2007, 9:39 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package assistedpostagger;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;

/**
 *
 * @author Paul Arezina
 */
public class POSTagComboBoxModel extends DefaultComboBoxModel {
    
    private ArrayList<String> abbreviations = new ArrayList();
    
    /** Creates a new instance of POSTagComboBoxModel */
    public POSTagComboBoxModel(Vector v, ArrayList al) {
        Iterator vi = v.iterator();
        while (vi.hasNext()) {
            this.addElement(vi.next());
        }
        abbreviations = al;
    }
    
    public ArrayList<String> getAbbreviations() {
        return abbreviations;
    }

    public void setAbbreviations(ArrayList<String> abbreviations) {
        this.abbreviations = abbreviations;
        
    }
    
    public String getSelectedAbbrev() {
        
        int selectedIndex = this.getIndexOf(this.getSelectedItem());
            
        String selectedAbbrev = abbreviations.get(selectedIndex);
        return selectedAbbrev;
        
    }
    
    public void setSelectedAbbrev(String abbrev) {
     
        int abbrevPosition = abbreviations.indexOf(abbrev);
        
        if (abbrevPosition >= 0) {
            
            String fullPOS = (String) this.getElementAt(abbrevPosition);
            this.setSelectedItem(fullPOS);
            
        }
        
    
    }
    
}
